<?php
namespace app\api\service\delivery;

use think\facade\Config;
use app\api\service\delivery\shansong\ShansongAdapter;
use app\api\service\delivery\fengniao\FengniaoAdapter;
use app\api\service\delivery\dada\DadaAdapter;

class PlatformFactory
{
    public static function create(string $platformName): PlatformInterface
    {
        $config = Config::get('delivery.platforms.' . $platformName, []);

        switch ($platformName) {
            case 'shansong_pro':
                return new ShansongAdapter($config);
            case 'fengniao_pro':
                return new FengniaoAdapter($config);
            case 'dada_pro':
                return new DadaAdapter($config);
            case 'shansong_dev':
                return new ShansongAdapter($config);
            case 'fengniao_dev':
                return new FengniaoAdapter($config);
            case 'dada_dev':
                return new DadaAdapter($config);
            default:
                throw new \InvalidArgumentException("不支持的配送平台: {$platformName}");
        }
    }
}